package com.jing.mapper;

import com.jing.pojo.SensorConfig;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author 陈书憬
 * @version 1.0
 * 2024/9/28
 */
@Mapper
public interface SensorMapper {
    @Insert("insert into sensor_config(id,room_id,room_name,create_time,dht_pin,fire_pin,led_pin,temperature,humidity,fire_status,led_status) values(#{id},#{roomId},#{roomName},#{createTime},#{dhtPin},#{firePin},#{ledPin},#{temperature},#{humidity},#{fireStatus},#{ledStatus})")
    void add(SensorConfig sensorConfig);

    @Select("select * from sensor_config where room_id=#{id};")
    void getIsSet(Integer id);

    @Select("select * from sensor_config where room_id=#{roomId};")
    List<SensorConfig> selectRoom(Integer roomId);

    @Update("update sensor_config set dht_pin = #{dhtPin}, fire_pin = #{firePin}, led_pin = #{ledPin} where room_id=#{roomId};")
    void update(String roomId, int dhtPin, int firePin, int ledPin);

    @Select("select * from sensor_config;")
    List<SensorConfig> selectAllRoomsList();

    @Delete("delete from sensor_config where room_id=#{id};")
    void deleteById(Integer id);

//    @Insert("insert into sensor_config(room_id,room_name,sensor_type,sensor_unit,sensor_address,sensor_status,sensor_description) values(#{sensorId},#{sensorName},#{sensorType},#{sensorUnit},#{sensorAddress},#{sensorStatus},#{sensorDescription})")
//    void add(SensorConfig sensorConfig);
}
